﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using nERP.Model.Fin;
using nERP.Model;

using nERP.Model.Po;


namespace nERP.ViewModel.Fin.PaymentDetailVMs
{
    public partial class PaymentDetailPayDetailListVM : BasePagedListVM<PaymentDetail, PaymentDetailDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("PaymentDetail", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("PaymentDetail", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<PaymentDetail>> InitGridHeader()
        {
            return new List<GridColumn<PaymentDetail>>{
                
                this.MakeGridHeader(x => x.ID).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.ID"].Value),
                this.MakeGridHeader(x => x.CreateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.UpdateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.CreateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.UpdateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.UpdateBy"].Value),
                this.MakeGridHeader(x => x.TenantCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Tenant"].Value),
                this.MakeGridHeader(x => x.Seq).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.序号"].Value),
                this.MakeGridHeader(x => x.PayDetailCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.付款明细单号"].Value),
                this.MakeGridHeader(x => x.BuyId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Buy>().GetSelectListItems(Wtm, x => x.BuyCode, x => x.BuyCode,SortByName:true)).SetTitle(@Localizer["Page.采购订单"].Value),
                this.MakeGridHeader(x => x.Amount1).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.单据金额"].Value),
                this.MakeGridHeader(x => x.Amount2).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.已结金额"].Value),
                this.MakeGridHeader(x => x.Amount3).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.未结金额"].Value),
                this.MakeGridHeader(x => x.Amount4).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.本次结算金额"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),
                this.MakeGridHeader(x => x.Status).SetEditType(EditTypeEnum.ComboBox,typeof(dStatusTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.状态"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<PaymentDetail> GetSearchQuery()
        {
                
            var id = (string)Searcher.PayId.ConvertValue(typeof(string));
            if (id == null)
                return new List<PaymentDetail>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<PaymentDetail>()
                .Where(x => id == x.PayId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class PaymentDetailDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._PaymentDetail._Pay")]
        public string PayId { get; set; }
    }

}

